﻿using System.Globalization;

namespace Compass.Maui.Converters;

public class RolesToEnableConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var preferenceService = Ioc.Default.GetRequiredService<IPreferenceService>();
        var role= preferenceService.Get(Consts.Role, string.Empty);
        return !string.IsNullOrEmpty(role) && value.ToString()!.Contains(role);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
public class RolesToReadOnlyConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var preferenceService = Ioc.Default.GetRequiredService<IPreferenceService>();
        var role = preferenceService.Get(Consts.Role, string.Empty);
        return string.IsNullOrEmpty(role) || !value.ToString()!.Contains(role);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}